from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean, Numeric, Computed, func, Float, Index
from sqlalchemy.orm import relationship
from ..database import Base

#region 公共业务信息相关的类

class Carrier(Base):
    """承运人(航空公司）信息表"""
    __tablename__ = 'Carrier'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    Code = Column(String(8), nullable=False)  # 承运人代码
    FullName = Column(String(64), nullable=False)  # 承运人全称
    BriefName = Column(String(50), nullable=False)  # 承运人简称
    TicketNoCode = Column(String(5), nullable=True)  # 票号代码
    ServiceTel = Column(String(64), nullable=True)  # 服务电话
    Memo = Column(String(256), nullable=True)  # 备注
    
class Airport(Base):
    """机场信息表"""
    __tablename__ = 'Airport'

    AirportId = Column(Integer, primary_key=True, autoincrement=True)
    Code = Column(String(8), nullable=False)    # 机场代码
    Name = Column(String(50), nullable=False)  # 机场名称
    FullName = Column(String(150), nullable=True)  # 机场全称
    CityName = Column(String(50), nullable=False)  # 城市名称
    CityPinYin = Column(String(50), nullable=False)  # 城市拼音
    CounterAddress = Column(String(512), nullable=True)  # 柜台地址
    CounterPhotoUrl = Column(String(512), nullable=True)  # 柜台照片
    IsInternational = Column(Boolean, nullable=True)  # 是否是国际机场
    EglishName = Column(String(128), nullable=True)  # 英文名称

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        # 在初始化时计算FullName
        if not self.FullName and self.CityPinYin and self.CityName and self.Name:
            pinyin_first = self.CityPinYin[0].upper() if self.CityPinYin else ''
            self.FullName = f"{pinyin_first} {self.CityName}{self.Name}"

class Airplane(Base):
    """飞机型号信息表"""
    __tablename__ = 'Airplane'

    AirplaneId = Column(Integer, primary_key=True, autoincrement=True)
    PlaneModel = Column(String(8), nullable=False)  # 飞机型号
    Shape = Column(String(8), nullable=False)  # 形状
    Company = Column(String(32), nullable=False)  # 公司
    MinSeatCount = Column(Integer, nullable=False)  # 最小座位数
    MaxSeatCount = Column(Integer, nullable=False)  # 最大座位数
    PhotoUrl = Column(String(128), nullable=False)


class HotelInfo(Base):
    """酒店信息表"""
    __tablename__ = 'HBEHotelInfo'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    HotelId = Column(String(128), nullable=False)   # 酒店id
    HotelName = Column(String(128), nullable=False)  # 酒店名称
    HotelEnglishName = Column(String(256), nullable=False)  # 酒店英文名称
    RankCode = Column(String(50), nullable=False)  # 酒店星级
    Address = Column(String(512), nullable=False)  # 酒店地址
    TrafficInfo = Column(String(1024), nullable=False)  # 交通信息
    Floor = Column(String(50), nullable=False)  # 楼层
    RoomQuantity = Column(String(50), nullable=False)  # 房间数量
    QuotaPerDays = Column(String(256), nullable=False)  # 每日配额
    Promotion = Column(String(50), nullable=False)  # 促销信息
    Telephone = Column(String(50), nullable=False)  # 联系电话
    BasicInfo = Column(String(2048), nullable=False)  # 基本信息
    Guarantee = Column(String(128), nullable=False)  # 担保信息
    Currency = Column(String(50), nullable=False)  # 货币
    CityCode = Column(String(50), nullable=False)  # 城市代码
    FAX = Column(String(50), nullable=False)  # 传真
    Exceptive = Column(String(50), nullable=False)  # 特殊条款
    AgentCommisionRate = Column(String(50), nullable=False)  # 代理佣金率
    GuaranteePolicy = Column(String(50), nullable=False)  # 担保政策
    Policy = Column(String(50), nullable=False)  # 政策
    YLPolicy = Column(String(50), nullable=False)  # 预留政策
    OpenDate = Column(String(50), nullable=False)  # 开业日期
    FitMent = Column(String(50), nullable=False)  # 装修情况
    PositionOfRemark = Column(String(50), nullable=False)  # 位置备注


class RoomType(Base):
    """酒店房间类型信息表"""
    __tablename__ = 'HBERoomType'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    hotel_info_id = Column(String(50), nullable=False)  # 酒店信息id,外键
    RoomCode = Column(String(50), nullable=False)  # 房间代码
    RoomName = Column(String(50), nullable=False)  # 房间名称
    Exceptive = Column(String(50), nullable=False)  # 特殊条款
    AgentCommisionRate = Column(String(50), nullable=False)  # 代理佣金率
    TeamRoom = Column(String(50), nullable=False)  # 团队房
    TeamRoomNum = Column(String(50), nullable=False)  # 团队房数量
    Floor = Column(String(50), nullable=False)  # 楼层
    RoomArea = Column(String(50), nullable=False)  # 房间面积
    NotAddBed = Column(String(50), nullable=False)  # 不加床
    BedType = Column(String(50), nullable=False)  # 床型
    Internet = Column(String(50), nullable=False)  # 互联网
    RoomTypeDesc = Column(String(512), nullable=False)  # 房间类型描述

#endregion

# region ERP系统相关的类
# 旅行社是一个工作区WorkArea，旅行社录入自己的CustomerProfile,然后为CustomerProfile创建多个PackageOrder
# 旅行社的PackageOrder里面的子类包含有多个AirticketOrder,HotelOrder,VehicleRental,MealOrder,AttractionTicket
class WorkArea(Base):
    """旅行社工作区信息表"""
    __tablename__ = "WorkArea"

    ID = Column(Integer, primary_key=True, autoincrement=True)  # 工作区ID
    Name = Column(String(50), nullable=False)  # 工作区名称
    EnglishName = Column(String(50), nullable=False) # 英文公司名
    LicenseNo = Column(String(50), nullable=False)  # 香港旅行社牌照号码
    ManagerName = Column(String(50), nullable=False)  # 工作区经理姓名
    ManagerUserNames = Column(String(200), nullable=True)  # 工作区经理用户名
    TelNo = Column(String(32), nullable=False)  # 工作区联系电话
    CityCode = Column(String(32), nullable=False)  # 工作区城市代码
    Address = Column(String(512), nullable=True)  # 工作区地址
    ResellerRank = Column(String(32), nullable=False)  # 分销商等级
    Memo = Column(String(512), nullable=True)  # 备注
    Balance = Column(Numeric(18, 2), nullable=False, default=0)  # 当前余额，旅行社要给我们充值系统使用费
    # 需要打印在打包订单pdf上面的：旅行社logo，旅行社名称，旅行社地址，旅行社联系电话，旅行社邮箱
    PDFLogoUrl = Column(String(512), nullable=True)  # 旅行社logo
    PDFName = Column(String(512), nullable=True)  # 旅行社名称
    PDFAddress = Column(String(512), nullable=True)  # 旅行社地址
    PDFContactName = Column(String(512), nullable=True)  # 联系人姓名
    PDFTelNo = Column(String(32), nullable=True)  # 旅行社联系电话
    PDFEmail = Column(String(32), nullable=True)  # 旅行社邮箱
    PDFBankInfo = Column(String(512), nullable=True)  # 旅行社银行信息

class WorkAreaTransaction(Base):
    """工作区(旅行社)充值记录表"""
    __tablename__ = 'WorkAreaTransaction'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    work_area_id = Column(Integer, nullable=False)  # 工作区id,外键
    TransactionType = Column(String(20), nullable=False)  # 交易类型：充值、消费、退款等
    Amount = Column(Numeric(18, 2), nullable=False)  # 交易金额
    Balance = Column(Numeric(18, 2), nullable=False)  # 交易后余额
    PaymentMethod = Column(String(20))  # 支付方式：银行转账、支付宝、微信等
    PaymentStatus = Column(String(20), nullable=False)  # 支付状态：待支付、已支付、已取消等
    PaymentTime = Column(DateTime)  # 支付时间
    CreateTime = Column(DateTime, nullable=False, default=func.now())
    CreatorUserName = Column(String(36), nullable=False)  # 创建人用户名
    CreatorName = Column(String(50), nullable=False)  # 创建人姓名
    TransactionNo = Column(String(50), unique=True, nullable=False)  # 交易流水号
    Remark = Column(String(500))  # 交易备注

# region 客户档案类
# 一个WorkArea可以有多个CustomerProfile，一个CustomerProfile可以有多个PackageOrder
# 一个CustomerProfile可以有多个CustomerPassenger，CustomerTelNo，CustomerAddress
# 一个CustomerProfile可以有多个AirticketOrder，HotelOrder，VehicleRental，MealOrder，AttractionTicket
class CustomerProfile(Base):
    """客户信息表"""
    __tablename__ = "CustomerProfile"

    ID = Column(Integer, primary_key=True, autoincrement=True)  # 客户档案id
    work_area_id = Column(Integer, nullable=False,
                          default=-1)  # 工作区id, 外键,默认值为-1

    CompanyName = Column(String(50), nullable=False)  # 所属公司名
    Name = Column(String(50), nullable=False)  # 客户姓名
    DisplayName = Column(String(50), nullable=False)  # 客户显示名称
    Sex = Column(String(10), nullable=False)  # 客户性别
    Birthday = Column(DateTime, nullable=False)  # 客户生日
    LegacyCustomerNo = Column(String(50), nullable=False)  # 客户编号
    CreateDateTime = Column(DateTime, nullable=False,
                            default=func.now())  # 创建时间
    CustomerLevel = Column(String(32), nullable=False)  # 客户等级
    Memo = Column(String(256), nullable=True)  # 备注
    # 需要打印在打包订单pdf上面的：客户姓名，客户电话，客户邮箱
    PDFName = Column(String(64), nullable=False)  # 客户姓名
    PDFTelNo = Column(String(64), nullable=False)  # 客户电话
    PDFAddress = Column(String(64), nullable=False)  # 客户地址
    PDFEmail = Column(String(64), nullable=False)  # 电子邮箱


class CustomerPassenger(Base):
    """客户乘客信息表"""
    __tablename__ = 'CustomerPassenger'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    customer_profile_id = Column(Integer, nullable=False)  # 客户档案id，外键
    Name = Column(String(32), nullable=False)  # 乘客姓名
    BirthdayDTS = Column(DateTime, nullable=False)  # 乘客生日, 只需要精确到年月日
    CertificateType = Column(String(32), nullable=False)  # 乘客证件类型
    CertificateNo = Column(String(64), nullable=True)  # 乘客证件号码


class CustomerTelNo(Base):
    """客户电话号码信息表"""
    __tablename__ = 'CustomerTelNo'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    customer_profile_id = Column(Integer, nullable=False)  # 客户档案id，外键
    TelNo = Column(String(32), nullable=False)  # 电话号码
    Owner = Column(String(64), nullable=False)  # 电话号码拥有者
    Email = Column(String(64), nullable=False)  # 电子邮箱


class CustomerAddress(Base):
    """客户地址信息表"""
    __tablename__ = 'CustomerAddress'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    customer_profile_id = Column(Integer, nullable=False)  # 客户档案id，外键
    Address = Column(String(512), nullable=False)  # 地址
    ContactName = Column(String(64), nullable=False)  # 联系人姓名
    ContactTelNo = Column(String(64), nullable=False)  # 联系人电话

#endregion

# region 打包订单类
# 一个PackageOrder可以有多个AirticketOrder，HotelOrder，VehicleRental，MealOrder，AttractionTicket
# 这个PackageOrder是旅行社为某个CustomerProfile创建的，所以PackageOrder里面有CustomerProfile的ID
# 主要用于打印打包订单pdf，和给CustomerProfile发送打包订单邮件，申请香港Elevy印花税，然后打印收据给Customer。
# 打印的时候需要显示WorkArea的相关logo和名称等抬头信息，也需要显示CustomerProfile的相关信息，还要显示里面的各类子订单信息和汇总价格，加上税和Elevy税的二维码
class PackageOrder(Base):
    """打包订单主表"""
    __tablename__ = "package_orders"

    ID = Column(Integer, primary_key=True, autoincrement=True)
    work_area_id = Column(Integer, nullable=False)
    customer_profile_id = Column(Integer, nullable=True)
    order_number = Column(String(50), nullable=True)
    title = Column(String(200), nullable=True)
    total_people = Column(Integer, nullable=True)
    start_date = Column(DateTime, nullable=True)
    end_date = Column(DateTime, nullable=True)
    customer_name = Column(String(50), nullable=True)
    customer_phone = Column(String(50), nullable=True)
    customer_email = Column(String(50), nullable=True)
    customer_company = Column(String(50), nullable=True)
    tax_rate = Column(Float, nullable=True, default=0.09)
    elevy_stamp_amount = Column(Float, nullable=True, default=0)
    status = Column(String(20), nullable=True, default='draft')
    pdf_url = Column(String(500), nullable=True)
    elevy_stamp_url = Column(String(500), nullable=True)
    internal_notes = Column(String(1000), nullable=True)
    customer_notes = Column(String(1000), nullable=True)
    terms_conditions = Column(String(2000), nullable=True)
    created_at = Column(DateTime, nullable=True)
    confirmed_at = Column(DateTime, nullable=True)
    created_user_name = Column(String(36), nullable=True)

# region 机票订单类
# 一个PackageOrder里面有多个AirticketOrder，没有PackageOrder也可以单独为WorkArea里面的某个CustomerProfile创建AirticketOrder
# 一个AirticketOrder里面有多个AirticketOrderPassenger，AirticketOrderFlight
class AirticketOrder(Base):
    """机票订单主表"""
    __tablename__ = 'AirticketOrder'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    work_area_id = Column(Integer, nullable=False, default=-1)  # 工作区id, 外键,默认值为-1
    package_order_id = Column(Integer, nullable=False, default=-1)  # 打包订单id, 外键,默认值为-1
    package_order_title = Column(String(200))  # 主订单标题
    customer_profile_id = Column(Integer, nullable=True)  # 客户档案id
    # 订单基本信息
    CreateTime = Column(DateTime, nullable=False, default=func.now())  # 创建时间
    CreatorUserName = Column(String(36), nullable=False)  # 创建人用户名
    CreatorName = Column(String(16), nullable=False)  # 创建人姓名
    ContactName = Column(String(32), nullable=False)  # 联系人姓名
    ContactTelNum = Column(String(32), nullable=False)  # 联系人电话
    
    BookRecordName = Column(String(32), nullable=False)  # 预订记录名称
    OfficeNo = Column(String(8), nullable=False)  # 办公室编号
    TicketType = Column(String(16), nullable=False)  # 票类型
    
    TotalPrice = Column(Numeric(12, 2), nullable=False)  # 总价
    TotalTicketPrice = Column(Numeric(12, 2), nullable=False)  # 总票面价格
    
    OrderStatus = Column(String(16), nullable=False)  # 订单状态
    CustomerConfirmed = Column(Boolean, nullable=False)  # 客户确认
    
    CustomerMemo = Column(String(256), nullable=False)  # 客户备注
    InternalMemo = Column(String(256), nullable=False)  # 内部备注
    
    Summary = Column(String(512), nullable=True)  # 摘要
    # 出票渠道
    IssueChannel = Column(String(16), nullable=False)  # 出票渠道
    
class AirticketOrderPassenger(Base):
    """机票订单乘客费用信息表"""
    __tablename__ = 'AirticketOrderPassenger'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    airticket_order_id = Column(Integer, nullable=False)  # 机票订单id
    
    PassengerName = Column(String(64), nullable=False)  # 乘客姓名
    PassengerType = Column(String(32), nullable=False)  # 乘客类型
    CertificateType = Column(String(32), nullable=False)  # 乘客证件类型
    CertificateNo = Column(String(64), nullable=True)  # 乘客证件号码
    Birthday = Column(DateTime, nullable=False)  # 乘客生日
    TicketPrice = Column(Numeric(12, 2), nullable=False)  # 票面价格
    AirportTax = Column(Numeric(12, 2), nullable=False)  # 机场税
    FuelTax = Column(Numeric(12, 2), nullable=False)  # 燃油税

class AirticketOrderFlight(Base):
    """机票订单航班信息表"""
    __tablename__ = 'AirticketOrderFlight'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    airticket_order_id = Column(Integer, nullable=False)  # 机票订单id
    
    FlightNo = Column(String(32), nullable=False)  # 航班号
    CabinCode = Column(String(8), nullable=False)  # 舱位代码
    DepAirportCode = Column(String(8), nullable=False)  # 出发机场代码
    ArrAirportCode = Column(String(8), nullable=False)  # 到达机场代码
    DepCityName = Column(String(32), nullable=False)  # 出发城市名称
    ArrCityName = Column(String(32), nullable=False)  # 到达城市名称
    DepDTS = Column(DateTime, nullable=False)  # 出发时间
    ArrDTS = Column(DateTime, nullable=False)  # 到达时间
    PriceMark = Column(String(32), nullable=True)  # 价格标记
    BasePrice = Column(Numeric(12, 2), nullable=False)  # 基础价格,Y舱全价
    TicketPrice = Column(Numeric(12, 2), nullable=False)  # 票面价格
    DiscountRate = Column(Numeric(12, 2), nullable=False)  # 折扣率
    OrgProfitRate = Column(Numeric(12, 2), nullable=False)  # 原始利润率
    ProfitRate = Column(Numeric(12, 2), nullable=False)  # 利润率
    ExtraProfitRate = Column(Numeric(12, 2), nullable=False)  # 额外利润率，后返
    AirportTax = Column(Numeric(12, 2), nullable=False)  # 机场税
    FuelTax = Column(Numeric(12, 2), nullable=False)  # 燃油税

#endregion


# region 酒店订单类
# 一个PackageOrder里面有多个HotelOrder，没有PackageOrder也可以单独为WorkArea里面的某个CustomerProfile创建HotelOrder
# 一个HotelOrder里面有多个HotelOrderPassenger
class HotelOrder(Base):
    """酒店订单主表，也是打包订单的一部分"""
    __tablename__ = 'HotelOrder'

    ID = Column(Integer, primary_key=True, autoincrement=True)    # 酒店订单id
    # 打包订单id
    work_area_id = Column(Integer, nullable=False, default=-1)  # 工作区id, 外键,默认值为-1
    package_order_id = Column(Integer, nullable=False, default=-1)  # 打包订单id, 外键,默认值为-1
    package_order_title = Column(String(200))  # 主订单标题
    customer_profile_id = Column(Integer, nullable=False)  # 客户档案id，外键

    # 酒店基本信息
    CityName = Column(String(64), nullable=False)  # 城市名称
    HotelName = Column(String(64), nullable=False)  # 酒店名称
    RoomType = Column(String(64), nullable=False)  # 房间类型
    RoomUnitPrice = Column(Numeric(18, 2), nullable=False)  # 房间单价
    BookRoomCount = Column(Integer, nullable=False)  # 预订房间数量
    TotalPrice = Column(Numeric(18, 2), nullable=False)  # 总价
    CheckInTime = Column(DateTime, nullable=False)  # 入住时间
    StayDayCount = Column(Integer, nullable=False)  # 入住天数
    ContactName = Column(String(64), nullable=False)  # 联系人姓名
    ContactTelNo = Column(String(64), nullable=False)  # 联系人电话
    CreatorName = Column(String(64), nullable=False)  # 创建人姓名
    CreatorUserName = Column(String(36), nullable=False)  # 创建人用户名
    CreateTime = Column(DateTime, nullable=False)  # 创建时间

class HotelOrderPassenger(Base):
    """酒店订单乘客信息表"""
    __tablename__ = 'HotelOrderPassenger'

    ID = Column(Integer, primary_key=True, autoincrement=True)
    hotel_order_id = Column(Integer, nullable=False)  # 酒店订单id
    Name = Column(String(64), nullable=False)  # 乘客姓名
    BirthdayDTS = Column(DateTime, nullable=False)  # 乘客生日
    CertificateType = Column(String(32), nullable=False)  # 乘客证件类型
    CertificateNo = Column(String(64), nullable=False)  # 乘客证件号码

#endregion

# region 其他PackageOrder的子订单类，租车订单，餐饮订单，景点门票订单，其他订单
class VehicleRental(Base):
    """打包订单里面的租车订单"""
    __tablename__ = "vehicle_rentals"

    ID = Column(Integer, primary_key=True, index=True)
    work_area_id = Column(Integer, nullable=False, default=-1)  # 工作区id
    package_order_id = Column(Integer)  # 主订单ID
    package_order_title = Column(String(200))  # 主订单标题
    
    vehicle_type = Column(String(50))  # 车辆类型（如：旅游大巴、小巴,商务车等，可自由输入）
    vehicle_count = Column(Integer)  # 几辆车
    rental_start_date = Column(DateTime)  # 租用开始日期
    rental_end_date = Column(DateTime)  # 租用结束日期
    days = Column(Integer)  # 租用天数
    daily_rate = Column(Float)  # 每日租金
    total_amount = Column(Float)  # 总金额
    currency = Column(String(3), default="HKD")  # 货币单位
    driver_included = Column(Boolean, default=True)  # 是否含司机
    notes = Column(String(500))  # 备注，车牌号等

class MealOrder(Base):
    """打包订单里面的餐饮订单"""
    __tablename__ = "meal_orders"

    ID = Column(Integer, primary_key=True, index=True)
    work_area_id = Column(Integer, nullable=False, default=-1)  # 工作区id
    package_order_id = Column(Integer)  # 主订单ID
    package_order_title = Column(String(200))  # 主订单标题
    
    meal_type = Column(String(30))  # 餐食类型（午餐/晚餐）
    number_of_people = Column(Integer)  # 用餐人数
    meal_count = Column(Integer)  # 用餐次数
    price_per_person = Column(Float)  # 每人价格
    total_amount = Column(Float)  # 总金额
    currency = Column(String(3), default="HKD")
    restaurant_name = Column(String(100))  # 餐厅名称
    restaurant_address = Column(String(200))  # 餐厅地址
    menu_details = Column(String(500))  # 菜单详情
    notes = Column(String(500))  # 备注

class AttractionTicket(Base):
    """打包订单里面的景点门票订单"""
    __tablename__ = "attraction_tickets"

    ID = Column(Integer, primary_key=True, index=True)
    work_area_id = Column(Integer, nullable=False, default=-1)  # 工作区id
    package_order_id = Column(Integer)  # 主订单ID
    package_order_title = Column(String(200))  # 主订单标题
    
    attraction_name = Column(String(100))  # 景点名称
    visit_date = Column(DateTime)  # 参观日期
    number_of_tickets = Column(Integer)  # 票数
    price_per_ticket = Column(Float)  # 每张票价格
    booking_fee = Column(Float)  # 预订手续费
    total_amount = Column(Float)  # 总金额
    currency = Column(String(3), default="HKD")
    ticket_type = Column(String(50))  # 票种类型（成人票/儿童票等）
    ticket_status = Column(String(20))  # 票务状态（已预订/已确认等）
    notes = Column(String(500))  # 备注
    
class OtherOrder(Base):
    """打包订单里面的其他订单"""
    __tablename__ = "other_orders"

    ID = Column(Integer, primary_key=True, index=True)
    work_area_id = Column(Integer, nullable=False, default=-1)  # 工作区id
    package_order_id = Column(Integer)  # 主订单ID
    package_order_title = Column(String(200))  # 主订单标题
    # 订单类别，可自行输入，如行李
    OrderType = Column(String(50))
    order_context = Column(String(50))  # 订单内容
    # 订单单价
    UnitPrice = Column(Float)
    # 订单人数
    OrderPeople = Column(Integer)
    # 每人预定数量
    OrderPeopleCount = Column(Integer)
    # 订单总金额,自动计算=单价*人数*每人预定数量
    TotalAmount = Column(Float)
    # 货币单位
    Currency = Column(String(3), default="HKD")
    notes = Column(String(500))  # 备注
    
class ElevyStamp(Base):
    """Elevy印花税类"""
    __tablename__ = "ElevyStamp"

    ID = Column(Integer, primary_key=True, autoincrement=True)
    work_area_id = Column(Integer, nullable=False, default=-1)  # 工作区id
    package_order_id = Column(Integer, nullable=False)  # 打包订单id
    package_order_title = Column(String(200))  # 主订单标题
    
    ReferenceNo = Column(String(50), nullable=False)  # 旅行社发送过去的参考编号，如2024-0001
    customer_name = Column(String(50), nullable=False)  # 客户姓名
    customer_phone = Column(String(50), nullable=False)  # 客户电话    
    package_order_total_amount = Column(Float, nullable=False)  # 打包订单总金额
    dep_date = Column(DateTime, nullable=False)  # 出发日期
    ElevyStampNo = Column(String(50), nullable=False)  # Elevy印花税号码，是一个二维码号码
    WorkAreaShortName = Column(String(50), nullable=False)  # 工作区简称
    WorkAreaLicNo = Column(String(50), nullable=False)  # 工作区牌照号码
    ElevyStampAmount = Column(Float, nullable=False)  # Elevy印花税金额
    ElevyStampCreateTime = Column(DateTime, nullable=False)  # Elevy印花税创建时间
    ElevyStampUrl = Column(String(500), nullable=False)  # Elevy印花税文件链接
    ElevyStampStatus = Column(String(20), nullable=False)  # Elevy印花税状态，有可能是已退状态
    RefundTime = Column(DateTime, nullable=True)  # 退税时间
#endregion
#endregion
#endregion

